<html>
<head>
		<meta charset="utf-8">
		<title>jQuery Validator 演示页面</title>		
	<link rel="stylesheet" href="http://www.365mini.com/static/js/layer/skin/layer.css" id="layui_layer_skinlayercss" style="">
</head>
<body>
<form action="http://www.365mini.com/">
    <div>
		<label>商品价格</label>：
		<input id="price" name="price" type="text">
	</div>
	<div>
		<label>商品数量</label>：
		<input id="amount" name="amount" type="text">
	</div>
	<div>
		<label>开始时间</label>：
		<input id="beginTime" name="beginTime" type="text">
	</div>
	<div>
		<label>身份证号码</label>：
		<input id="idcard" name="idcard" placeholder="请输入18位身份证号码" type="text">
	</div>
	<input type="submit" value="提交">
</form>
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<script src="http://www.365mini.com/static/js/layer/layer.js"></script>
<script src="http://www.365mini.com/static/js/jquery-validator-1.3.js"></script>
<script type="text/javascript">
	// 为了让提示更美观，扩展jQuery原型对象，添加layer的tips方法
	$.fn.tips = function(msg, delay){
		layer.tips(msg, this, delay || 3000);
	};

	var v = new V();

	v.define({
		"price": {
			format: "number/money", // 必须是两位小数以内的数字
			range: "(0,]" //  商品价格大于0
		},
		"amount": {
			format: "number", // 默认为"int"，即必须为整数
			range: "(0,)" // 商品数量必须大于0
		},
		"beginTime": {
			format:"date", // 默认expression为"yyyy-MM-dd"
			compare: "this < now",
			message: {
				compare: "{label}不能大于当前时间!"
			}
		},
		"idcard": {
			// 只允许二代以上身份证，且必须年满18周岁
			format:"idcard/18:[18,]"
		}	
	});

	// 在表单提交时执行以上规则校验
	$("form").v("submit", {
		"#price": "price",
		"#amount": "amount",
		"#beginTime": "beginTime",
		"#idcard": "idcard"
	});
</script>

</body></html>